﻿@model Jb.Web.ViewModels.UtilityModels.ListConfig
@using Jb.Common.Extensions;
@using Jb.Web.Utility;
@using Jb.Web.ViewModels;
@{
    String _Keyword = Jb.Common.DB.NullHandler.GetString(ViewData[AppConstants.ViewDataKeys.SEARCH_KEY]);
    String pageTitle = "Search Jobs";
    ViewBag.Title = Html.GetPageTitle(pageTitle);
    
    Jb.Web.ViewModels.UtilityModels.PagerConfig _PagerConfig = Model.Pager;
    //ViewBag.DataSource = Model.DataSource;
    //ViewBag.TotalRecord = Model.Pager.TotalRecord;
    _PagerConfig.UrlFormat = "/job/search?key=" + _Keyword + "&pageNo={0}";
    if (_Keyword.IsNullOrEmpty())
    {
        ViewBag.ShowMessage = false;
    }
    ViewData[AppConstants.ViewDataKeys.CALCULATE_OCCURANCE] = true;
    ///Getis
    if (Model.DataSource == null){
        Model.DataSource = new System.Data.DataTable();
    }

    ViewData[AppConstants.ViewDataKeys.HIDE_ADD_TO_FAVORITE] = false;
}
<div class="jb-page-heading">
    <h1>@pageTitle</h1>
    <div>
        @if(_Keyword.IsNullOrEmpty()){
            <text>Enter your keyword in the following text box and click Search.</text>
        }
        else {
        <text>List of matched job(s) for your given search keyword.</text>
        }
    </div>
</div>

@{String autoClass = _Keyword.IsNullOrEmpty() ? String.Empty : "auto";}
<div class="jb-page-content @(autoClass)">
    @using (Html.BeginForm("search", "job", FormMethod.Post, new { id="frmSearch", style="margin:0px;"}))
    {
    <div class="span6">
        <div class="input-append">
            <input id="txtKeyword" name="keyword" type="text" maxlength="100" value="@_Keyword" placeholder="Enter your keyword" />        
            <button class="btn btn-primary" type="submit"><i class="icon-search icon-white"></i> Search</button>
        </div>
    </div>    
    <div class="span3">        
        <button class="btn" type="button" onclick="ShowSearchTips();"><i class="icon-hand-right"></i> Search Tips</button>        
    </div>
    <div class="clearfix"></div>
    }    
</div>

<div id="divSearchResult">
    @Html.Partial("_JobList", Model.DataSource)
    @if (_PagerConfig != null && !_Keyword.IsNullOrEmpty())
    {
        autoClass = _PagerConfig.TotalRecord > 0 ? "auto" : String.Empty;
        <div class="jb-page-content @(autoClass)">
        @Html.Partial("_Pager", _PagerConfig)
        </div>
    }
</div>


@*Modal Section Starts*@
<div id="divSearchTipsDialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="divPhotoEditModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
        <h4 id="myModalLabel">Job Search Tips</h4>
    </div>
    <div class="modal-body jb-inline-label">            
        <div id="divModalMesssage">
            <a href="/">@ConfigReader.SiteName</a>'s search engine supports several techniques of search. 
            You can specify them in your search keyword. They are preety simple and you can try few of them. 
            Suppose you are looking for a Web Designer job, then you can format your keywords in following ways:
            <ul class="search-tips">
                <li>
                    If you want a exact match in your search result then sorrund your keyword with a <b>double quote</b> (")<br />
                    <b>Example:</b> "Web Designer"
                </li>
                <li>
                    If you want to match all of your keywords, then you can use <b>and</b> operator.<br />
                    <b>Example:</b> Web AND Designer
                </li>
                <li>
                    If you want to match few of your keywords, then you can try <b>or</b> operator.<br />
                    <b>Example:</b> Web OR Designer
                </li>
                <li>
                    Or you can simply enter your search criteria about what you are looking for and 
                    @ConfigReader.SiteName's search engine will intelligently show matching jobs.
                </li>
            </ul>
        </div>
    </div>
    <div class="modal-footer">        
        <button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-off"></i> Close</button>
    </div>
</div>
@*Modal Section Ends*@

@Html.Partial("_SendToFriendModal")

@section RightSideBar
{
<div style="height:330px;">
    <ul>
        <li><h3>Space for rent</h3></li>
    </ul>    
</div>
}

@section PageHeadSection
{
    <style type="text/css">
        #txtKeyword{width:100%; font-size:19px;}
        @if(Model.Pager != null && Model.Pager.TotalRecord > 2){
        @: .jb-page-content{min-height:auto; height:auto;}
        }
    </style>
}

@section JavaScriptPlaceHolder
{
@Html.JavaScript("Common.js", Url)
@Html.JavaScript("jquery.validate.min.js", Url)
@Html.JavaScript("jquery.validate.unobtrusive.min.js", Url)
@Html.Partial("_SendToFriendJS")
<script language="javascript" type="text/javascript">
    function ShowSearchTips() {
        $('#divSearchTipsDialog').modal({ show: true });
    }    
</script>
}
